﻿package {
	import flash.ui.GameInput;

	public class node {
		
		var gameState:gamestate;
		var left:node;
		var right:node;
		var isRoot:Boolean;
		var depth:Number;
		var evaluation:Number;
		var actionTaken:Number = -100;
		
		public function node(currentGameState:gamestate, depth:Number, root:Boolean = false):void {
			gameState = currentGameState
			this.depth = depth;
			this.evaluation = -currentGameState.getUntouchedEdges().length*100 - currentGameState.getStepsSinceStart() * .1 /*+ currentGameState.getManhattanDistanceFromStart() * .1*/;
		}
		
		public function setRight(nodeRight:node):void {
			right = nodeRight;
		}
		
		public function setGameState(currentGameState:gamestate):void {
			gameState = currentGameState;
		}
		
		public function setLeft(nodeLeft:node):void {
			left = nodeLeft;
		}
		
		public function getGameState():gamestate {
			return gameState;
		}
		
		public function getLeft():node {
			return left;
		}
		
		public function getRight():node {
			return right;
		}
		
		public function setIsRoot(isRoot:Boolean):void {
			this.isRoot = isRoot;
		}
		
		public function getIsRoot():Boolean {
			return isRoot;
		}
		
		public function setDepth(depthToSet:Number):void {
			depth = depthToSet;
		}
		
		public function getDepth():Number {
			return depth;
		}
		
		public function setEvaluation(evaluation:Number):void {
			this.evaluation = evaluation;
		}
		
		public function getEvaluation():Number {
			return evaluation;
		}
		
		public function setActionTaken(actionToSet:Number):void {
			this.actionTaken = actionToSet;
		}
		
		public function getActionTaken():Number {
			return this.actionTaken;
		}
		
		public function equals(testNode:node):Boolean {
			if (this.gameState.equals(testNode.getGameState())) {
				return true;
			} else {
				return false;
			}
		}
	}
}